﻿//-----------------------------------------------------------------------
// <copyright file="AppDomainDataContract.cs" company="CodePlex">
//     Copyright (c) Doug Holland, CodePlex. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace CodePlex.Diagnostics.Silverlight.Contracts
{
    using System;

    using System.Runtime.Serialization;

    /// <summary>
    /// Defines the data contract representing the details of an application domain.
    /// </summary>
    [DataContract(Name = "AppDomainDataContract", Namespace = "http://schemas.datacontract.org/2004/07/CodePlex.Diagnostics.Contracts")]
    public sealed class AppDomainDataContract
    {
        #region public AppDomainDataContract()

        /// <summary>
        /// Initializes a new instance of the <see cref="T:AppDomainDataContract"/> class.
        /// </summary>
        public AppDomainDataContract()
        {
            this.BaseDirectory = null;

            //if (AppDomain.CurrentDomain.DomainManager != null)
            //{
            //    this.DomainManager = AppDomain.CurrentDomain.DomainManager.ToString();
            //}

            this.DomainManager = string.Empty;

            this.DynamicDirectory = null;

            //this.FriendlyName = AppDomain.CurrentDomain.FriendlyName;

            this.FriendlyName = string.Empty;

            this.Id = null;

            this.RelativeSearchPath = null;
        }

        #endregion

        #region public string BaseDirectory

        /// <summary>
        /// Gets the base directory that the assembly resolver uses to probe for assemblies.
        /// </summary>
        /// <value>The base directory that the assembly resolver uses to probe for assemblies.</value>
        [DataMember]
        public string BaseDirectory
        {
            get;
            private set;
        }

        #endregion

        #region public string DomainManager

        /// <summary>
        /// Gets the domain manager that was provided by the host when the application domain was initialized.
        /// </summary>
        /// <value>The domain manager that was provided by the host when the application domain was initialized.</value>
        [DataMember]
        public string DomainManager
        {
            get;
            private set;
        }

        #endregion

        #region public string DynamicDirectory

        /// <summary>
        /// Gets the directory that the assembly resolver uses to probe for dynamically-created assemblies.
        /// </summary>
        /// <value>Get the directory that the assembly resolver uses to probe for dynamically-created assemblies.</value>
        [DataMember]
        public string DynamicDirectory
        {
            get;
            private set;
        }

        #endregion

        #region public string FriendlyName

        /// <summary>
        /// Gets the friendly name of this application domain.
        /// </summary>
        /// <value>The friendly name of this application domain.</value>
        [DataMember]
        public string FriendlyName
        {
            get;
            private set;
        }

        #endregion

        #region public int? Id

        /// <summary>
        /// Gets an integer that uniquely identifies the application domain within the process. 
        /// </summary>
        /// <value>An integer that identifies the application domain.</value>
        [DataMember]
        public int? Id
        {
            get;
            private set;
        }

        #endregion

        #region public string RelativeSearchPath

        /// <summary>
        /// Gets the path under the base directory where the assembly resolver should probe for private assemblies. 
        /// </summary>
        /// <value>The path under the base directory where the assembly resolver should probe for private assemblies.</value>
        [DataMember]
        public string RelativeSearchPath
        {
            get;
            private set;
        }

        #endregion
    }
}
